package com.own.business.wechat.base.controller;

import com.own.business.wechat.base.entity.query.WechatUserQuery;
import com.own.business.wechat.base.entity.vo.WechatUserVo;
import com.own.business.wechat.base.service.WechatUserService;
import com.own.component.common.base.controller.BaseController;
import com.own.component.common.model.PageModel;
import com.own.component.common.model.R;
import com.own.component.common.model.ResultModel;
import com.own.component.log.operation.aop.LogOperationAop;
import com.own.constant.ConstantApiPrefix;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * WechatUserController
 *
 * @author chenxueli
 * @date 2023-06-30 10:14:13
 */
@Slf4j
@Tag(name = "微信用户" + ConstantBeanSuffix.CONTROLLER)
@RestController
@RequestMapping(ConstantApiPrefix.BASE_API_V1_PREFIX + "wechat/user")
public class WechatUserController extends BaseController {

    @Resource
    private WechatUserService wechatUserService;

    @LogOperationAop
    @Operation(summary = "分页查询信息")
    @PostMapping("/page")
    public ResultModel<PageModel<WechatUserVo>> page(
            @RequestBody WechatUserQuery query
    ) {
        var pageModel = wechatUserService.page(query);
        return R.success(pageModel);
    }

    @LogOperationAop
    @Operation(summary = "根据id获取信息")
    @GetMapping("/{wechatUserId}")
    public ResultModel<WechatUserVo> getById(
            @Parameter(description = "主键id", required = true) @PathVariable Long wechatUserId
    ) {
        var vo = wechatUserService.getById(wechatUserId);
        return R.success(vo);
    }

}
